package com.cloud.server.cloudserver.listen;

import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceCanceledEvent;
import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRegisteredEvent;
import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRenewedEvent;
import org.springframework.cloud.netflix.eureka.server.event.EurekaRegistryAvailableEvent;
import org.springframework.cloud.netflix.eureka.server.event.EurekaServerStartedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Component
public class ServiceStatusListener {

	//服务下线
	@EventListener
	public void listener(EurekaInstanceCanceledEvent event){
		System.out.println("服务下线:"+event.getServerId()+","+event.getAppName());
	}
	//服务注册
	@EventListener
	public void listener(EurekaInstanceRegisteredEvent event){
		System.out.println("服务正在注册:"+event.getInstanceInfo().getAppName());
	}
	//eureka启动监听
	@EventListener
	public void listener(EurekaRegistryAvailableEvent event){
		System.out.println("注册中心启动:"+event.getSource());
	}
	//服务续约,心跳监听
	@EventListener
	public void listener(EurekaInstanceRenewedEvent event){
		System.out.println("服务心跳:"+event.getServerId()+","+event.getAppName());
	}
	//eureka server 启动监听
	@EventListener
	public void listener(EurekaServerStartedEvent event){
		System.out.println("eureka server启动:"+event.getSource());
	}

}
